<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <script src="../lib/vue.js"></script>
  </head>

  <body>
    <div id="app">
      <cpn :cmessage="message"></cpn>
    </div>
    <template id="cpn">
      <div>
        <h2>{{cmessage}}</h2>
        <p>{{cmovies}}</p>
      </div>
    </template>
    <script>
      // 父传子 props
      const cpn = {
        template: '#cpn',
        // props: ['cmovies', 'cmessage'], //方法1 数组
        props: {
          // 方法2 对象 可以设定数据类型和默认值
          cmovies: {
            // 对象是数组或者对象时，默认值必须是函数
            type: Array,
            default() {
              return ['少林寺']
            }
          },
          cmessage: {
            type: String,
            default: 'aa'
          }
        },
        data() {
          return {}
        },
        methods: {}
      }
      var vm = new Vue({
        el: '#app',
        data: {
          message: '标题',
          movies: ['Hier', '海泽旺', '变形金刚']
        },
        methods: {},
        components: {
          cpn
        }
      })
    </script>
  </body>
</html>
